-diff --git a/.gitignore b/.gitignore
-new file mode 100644
-index 0000000..920cdfc
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+mDNSPosix/build
+mDNSPosix/objects
+
-diff --git a/mDNSPosix/PosixDaemon.c b/mDNSPosix/PosixDaemon.c
-index 88b3292..e86a6c7 100644
--- a/mDNSPosix/PosixDaemon.c
+++ b/mDNSPosix/PosixDaemon.c
@@ -37,6 +37,11 @@
if (mStatus_NoError == err)
err = MainLoop(&mDNSStorage);
-diff --git a/mDNSPosix/Responder.c b/mDNSPosix/Responder.c
-index 3996b7b..e58d8eb 100755
--- a/mDNSPosix/Responder.c
+++ b/mDNSPosix/Responder.c
-@@ -603,7 +603,8 @@ static mStatus RegisterServicesInFile(const char *filePath)
+@@ -603,7 +603,8 @@ static mStatus RegisterServicesInFile(co
status = mStatus_UnknownErr;
}
return status;
}
-diff --git a/mDNSPosix/mDNSPosix.c b/mDNSPosix/mDNSPosix.c
-index 953bf64..4e481ea 100755
--- a/mDNSPosix/mDNSPosix.c
+++ b/mDNSPosix/mDNSPosix.c
-@@ -136,7 +136,7 @@ mDNSlocal void SockAddrTomDNSAddr(const struct sockaddr *const sa, mDNSAddr *ipA
+@@ -136,7 +136,7 @@ mDNSlocal void SockAddrTomDNSAddr(const
// mDNS core calls this routine when it needs to send a packet.
mDNSexport mStatus mDNSPlatformSendUDP(const mDNS *const m, const void *const msg, const mDNSu8 *const end,
mDNSIPPort dstPort, mDNSBool useBackgroundTrafficClass)
{
int err = 0;
-@@ -574,9 +574,17 @@ mDNSlocal void FreePosixNetworkInterface(PosixNetworkInterface *intf)
+@@ -574,9 +574,17 @@ mDNSlocal void FreePosixNetworkInterface
{
assert(intf != NULL);
if (intf->intfName != NULL) free((void *)intf->intfName);
#endif
free(intf);
}
-@@ -703,6 +711,29 @@ mDNSlocal int SetupSocket(struct sockaddr *intfAddr, mDNSIPPort port, int interf
+@@ -703,6 +711,29 @@ mDNSlocal int SetupSocket(struct sockadd
if (err < 0) { err = errno; perror("setsockopt - IP_MULTICAST_TTL"); }
}
// And start listening for packets
if (err == 0)
{
-@@ -784,6 +815,29 @@ mDNSlocal int SetupSocket(struct sockaddr *intfAddr, mDNSIPPort port, int interf
+@@ -784,6 +815,29 @@ mDNSlocal int SetupSocket(struct sockadd
if (err < 0) { err = errno; perror("setsockopt - IPV6_MULTICAST_HOPS"); }
}
// And start listening for packets
if (err == 0)
{
-@@ -815,7 +869,12 @@ mDNSlocal int SetupSocket(struct sockaddr *intfAddr, mDNSIPPort port, int interf
+@@ -815,7 +869,12 @@ mDNSlocal int SetupSocket(struct sockadd
}
// Clean up
assert((err == 0) == (*sktPtr != -1));
return err;
}
-@@ -994,7 +1053,7 @@ mDNSlocal mStatus OpenIfNotifySocket(int *pFD)
+@@ -994,7 +1053,7 @@ mDNSlocal mStatus OpenIfNotifySocket(int
/* Subscribe the socket to Link & IP addr notifications. */
mDNSPlatformMemZero(&snl, sizeof snl);
snl.nl_family = AF_NETLINK;
ret = bind(sock, (struct sockaddr *) &snl, sizeof snl);
if (0 == ret)
*pFD = sock;
-@@ -1072,11 +1131,18 @@ mDNSlocal mDNSu32 ProcessRoutingNotification(int sd)
+@@ -1072,11 +1131,18 @@ mDNSlocal mDNSu32 ProcessRoutingNo
PrintNetLinkMsg(pNLMsg);
#endif
// Advance pNLMsg to the next message in the buffer
if ((pNLMsg->nlmsg_flags & NLM_F_MULTI) != 0 && pNLMsg->nlmsg_type != NLMSG_DONE)
-@@ -1247,8 +1313,12 @@ mDNSexport mStatus mDNSPlatformInit(mDNS *const m)
+@@ -1247,8 +1313,12 @@ mDNSexport mStatus mDNSPlatformInit(mDNS
if (err == mStatus_NoError) err = SetupSocket(&sa, zeroIPPort, 0, &m->p->unicastSocket6);
#endif
// Tell mDNS core about DNS Servers
mDNS_Lock(m);
-@@ -1281,9 +1351,17 @@ mDNSexport void mDNSPlatformClose(mDNS *const m)
+@@ -1281,9 +1351,17 @@ mDNSexport void mDNSPlatformClose(mDNS *
{
assert(m != NULL);
ClearInterfaceList(m);
#endif
}
-@@ -1533,14 +1611,14 @@ mDNSexport mStatus mDNSPlatformClearSPSMACAddr(void)
+@@ -1533,14 +1611,14 @@ mDNSexport mStatus mDNSPlatformClearS
mDNSexport mDNSu16 mDNSPlatformGetUDPPort(UDPSocket *sock)
{
(void) sock; // unused
return mDNSfalse;
}
-diff --git a/mDNSPosix/mDNSUNP.c b/mDNSPosix/mDNSUNP.c
-index b392fc7..9f85e0e 100755
--- a/mDNSPosix/mDNSUNP.c
+++ b/mDNSPosix/mDNSUNP.c
@@ -61,154 +61,86 @@
#if defined(AF_INET6) && HAVE_IPV6 && HAVE_LINUX
-#include <netdb.h>
-#include <arpa/inet.h>
--
++#include <sys/types.h>
++#include <ifaddrs.h>
+
-/* Converts a prefix length to IPv6 network mask */
-void plen_to_mask(int plen, char *addr) {
- int i;
- plen -= ones_in_block;
- }
-}
-+#include <sys/types.h>
-+#include <ifaddrs.h>
-+
-/* Gets IPv6 interface information from the /proc filesystem in linux*/
-struct ifi_info *get_ifi_info_linuxv6(int family, int doaliases)
- ifihead = NULL;
- ifipnext = &ifihead;
- lastname[0] = 0;
-+ struct ifaddrs *ifap, *ifa;
-+ struct ifi_info *ifi = NULL, *head = NULL;
-
+-
- if ((fp = fopen(PROC_IFINET6_PATH, "r")) != NULL) {
- sockfd = socket(AF_INET6, SOCK_DGRAM, 0);
- if (sockfd < 0) {
- goto gotError;
-+ /* doaliases seems always true in the calls in current code */
-+ assert(doaliases);
-+
-+ if (getifaddrs(&ifap) < 0)
-+ {
-+ return NULL;
-+ }
-+ for (ifa = ifap ; ifa ; ifa = ifa->ifa_next)
-+ {
-+ /* Care only about IPv6 addresses on non-point-to-point links. */
-+ if (!ifa->ifa_addr
-+ || ifa->ifa_addr->sa_family != AF_INET6)
-+ continue;
-+ ifi = calloc(1, sizeof(*ifi));
-+ if (!ifi)
-+ break;
-+ strncpy(ifi->ifi_name, ifa->ifa_name, IFI_NAME);
-+ /* We ignore ifi_{haddr,hlen}, everyone else does too */
-+ ifi->ifi_flags = ifa->ifa_flags;
-+ /* We ignore ifi_myflags; IFI_ALIAS isn't used anywhere */
-+ ifi->ifi_index = if_nametoindex(ifa->ifa_name);
-+ if (!(ifi->ifi_addr = malloc(sizeof(struct sockaddr_in6))))
-+ break;
-+ memcpy(ifi->ifi_addr, ifa->ifa_addr, sizeof(struct sockaddr_in6));
-+
-+ if (ifa->ifa_netmask)
-+ {
-+ if (!(ifi->ifi_netmask = malloc(sizeof(struct sockaddr_in6))))
-+ break;
-+ memcpy(ifi->ifi_netmask, ifa->ifa_netmask,
-+ sizeof(struct sockaddr_in6));
- }
+- }
- while (fscanf(fp,
- "%4s%4s%4s%4s%4s%4s%4s%4s %02x %02x %02x %02x %8s\n",
- addr[0],addr[1],addr[2],addr[3],
- if (ifi == NULL) {
- goto gotError;
- }
-
+-
- ifipold = *ifipnext; /* need this later */
- ifiptr = ifipnext;
- *ifipnext = ifi; /* prev points to this new one */
- goto gotError;
- }
- memcpy(ifi->ifi_addr, res0->ai_addr, sizeof(struct sockaddr_in6));
-+ if (!(ifi->ifi_addr = malloc(sizeof(struct sockaddr_in6))))
-+ break;
-+ memcpy(ifi->ifi_addr, ifa->ifa_addr, sizeof(struct sockaddr_in6));
-
+-
- /* Add netmask of the interface */
- char ipv6addr[INET6_ADDRSTRLEN];
- plen_to_mask(plen, ipv6addr);
- }
- }
- goto done;
++ struct ifaddrs *ifap, *ifa;
++ struct ifi_info *ifi = NULL, *head = NULL;
-gotError:
- if (ifihead != NULL) {
- if (res0 != NULL) {
- freeaddrinfo(res0);
- res0=NULL;
-- }
++ /* doaliases seems always true in the calls in current code */
++ assert(doaliases);
++
++ if (getifaddrs(&ifap) < 0)
++ {
++ return NULL;
+ }
-done:
- if (sockfd != -1) {
- assert(close(sockfd) == 0);
++ for (ifa = ifap ; ifa ; ifa = ifa->ifa_next)
++ {
++ /* Care only about IPv6 addresses on non-point-to-point links. */
++ if (!ifa->ifa_addr
++ || ifa->ifa_addr->sa_family != AF_INET6)
++ continue;
++ ifi = calloc(1, sizeof(*ifi));
++ if (!ifi)
++ break;
++ strncpy(ifi->ifi_name, ifa->ifa_name, IFI_NAME);
++ /* We ignore ifi_{haddr,hlen}, everyone else does too */
++ ifi->ifi_flags = ifa->ifa_flags;
++ /* We ignore ifi_myflags; IFI_ALIAS isn't used anywhere */
++ ifi->ifi_index = if_nametoindex(ifa->ifa_name);
++ if (!(ifi->ifi_addr = malloc(sizeof(struct sockaddr_in6))))
++ break;
++ memcpy(ifi->ifi_addr, ifa->ifa_addr, sizeof(struct sockaddr_in6));
++
++ if (ifa->ifa_netmask)
++ {
++ if (!(ifi->ifi_netmask = malloc(sizeof(struct sockaddr_in6))))
++ break;
++ memcpy(ifi->ifi_netmask, ifa->ifa_netmask,
++ sizeof(struct sockaddr_in6));
++ }
++
++ if (!(ifi->ifi_addr = malloc(sizeof(struct sockaddr_in6))))
++ break;
++ memcpy(ifi->ifi_addr, ifa->ifa_addr, sizeof(struct sockaddr_in6));
++
++
+ if (ifa->ifa_flags & IFF_POINTOPOINT && ifa->ifa_dstaddr)
+ {
+ if (!(ifi->ifi_dstaddr = malloc(sizeof(struct sockaddr_in6))))
#endif // defined(AF_INET6) && HAVE_IPV6 && HAVE_LINUX
struct ifi_info *get_ifi_info(int family, int doaliases)
-@@ -229,7 +161,7 @@ struct ifi_info *get_ifi_info(int family, int doaliases)
+@@ -229,7 +161,7 @@ struct ifi_info *get_ifi_info(int family
#endif
#if defined(AF_INET6) && HAVE_IPV6 && HAVE_LINUX
#endif
sockfd = -1;
-diff --git a/mDNSPosix/mDNSUNP.h b/mDNSPosix/mDNSUNP.h
-index cc81b7d..e710087 100755
--- a/mDNSPosix/mDNSUNP.h
+++ b/mDNSPosix/mDNSUNP.h
@@ -97,8 +97,7 @@ struct ifi_info {
#endif
#if defined(AF_INET6) && HAVE_IPV6
-diff --git a/mDNSShared/dnsextd_parser.y b/mDNSShared/dnsextd_parser.y
-index 18c5990..d4b63ce 100644
--- a/mDNSShared/dnsextd_parser.y
+++ b/mDNSShared/dnsextd_parser.y
@@ -15,6 +15,8 @@